using IQIGame.Onigao.Framework;
using System;

namespace IQIGame.Onigao.Game
{
    public static class UIGlobalEventControllerFactory
    {
        private static bool isInited = false;
        private static Func<IUIGlobalEventController> createEventController;

        public static void RegisterCreateFunc(Func<IUIGlobalEventController> func)
        {
            if (isInited)
            {
                LogGame.LogError("禁止重复初始化");
                return;
            }
            createEventController = func;
            isInited = true;
        }

        public static IUIGlobalEventController Create()
        {
            return createEventController?.Invoke();
        }

        public static void Release(IUIGlobalEventController ctrl)
        {
            ctrl.Put2Pool();
        }
    }
}
